package samples.d2.lines 
{
	import adobe.utils.CustomActions;
	import flash.utils.setInterval;
	import samples.BaseSample;
	import shapes.shapes2D.Dot;
	import shapes.shapes2D.Line;
	
	/**
	 * @author Nicolas Barradeau
	 * http://en.nicoptere.net
	 */
	public class Lines2 extends BaseSample
	{
		
		private var dots:Vector.<Dot>;
		
		public function Lines2() 
		{
			
			dots = new Vector.<Dot>();
			var i:int = 100;
			while ( i-- )
			{
				dots.push( new Dot( 100 + ( sw - 200 ) * Math.random(), 100 + ( sh - 200 ) * Math.random() ) );
			}
			interval = setInterval( update, 1000 );
			update();
		}
		
		private function update():void
		{
			graphics.clear();
			graphics.lineStyle( 0, color );
			for each( var d:Dot in dots )
			{
				d.draw( graphics );
			}
			
			var i:int = 10, r0:int, r1:int;
			r0 = int( Math.random() * dots.length );
			while ( i-- )
			{
				r1 = int( Math.random() * dots.length );
				var l:Line = new Line( dots[ r0 ] , dots[ r1 ] );
				r0 = r1;
				l.draw( graphics );
			}
			
		}
		
	}

}